package com.itstudy.validation;

import com.itstudy.anno.State;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class StateValidation implements ConstraintValidator<State,String> {
    /**
     *
      * @param s 将来要校验的数据
     * @param constraintValidatorContext
     * @return 若返回false，则校验不通过，返回true，通过
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if(s==null) {
            return false;
        }
        if(s.equals("已发布")||s.equals("草稿")) {
            return true;
        }
        return false;

    }
}
